<template>
	<view>
		<view
			v-if="!loading && list.length > 0"
		>
			<view
				v-for="(item, index) in list"
				:key="index"
				class="bg-white pad-10 mar-x-10 mar-t-10"
				@click.stop="toDetails(item)"
			>
				<view class="flex justify-between align-center text-nowrap font-14">
					<view class="font-b-800">
						<text>申请单号：</text>
						<text>{{ item.repairTaskNum }}</text>
					</view>
					
					<view>
						<text>申请时间：</text>
						<text>{{ item.createDate }}</text>
					</view>
				</view>
				
				<view class="font-14 mar-y-10">
					<text>车号：</text>
					<text>{{ item.repairVehicle.vehicleNumber }}</text>
				</view>
				
				<Lines w="100%" h="1px" bg="#e6e6e6" />
				
				<view class="flex justify-between align-center font-14 mar-t-10">
					<view>
						<text>客户：</text>
						<text>{{ item.customer.cname }}</text>
					</view>
				</view>
			</view>
		</view>
		
		<view v-if="list.length > 0 && list.length === total && !loading" class="flex justify-center mar-t-40 pad-b-20 color-999999">
			<text>~ 没有更多数据了</text>
		</view>
		
		<!-- 页面加载 -->
		<view v-if="loading" class="mar-t-20">
			<u-loading-icon :loading="loading" text="加载中..." mode="circle" color="#1e9fff" textColor="#1e9fff" fontSize="16px"></u-loading-icon>
		</view>
		
		<!-- 空数据 -->
		<view v-if="list.length === 0 && !loading" class="mar-t-100">
			<u-empty
				mode="data"
				text="~暂无数据"
			></u-empty>
		</view>
	</view>
</template>

<script>
	import Utils from '@/utils/utils'
	import Lines from '@/components/Lines/index'
	import { mapState } from 'vuex'
	import { getExamineList } from '@/apis/repairManagerExamine/index'
	
	export default {
		components: {
			Lines,
		},
		
		computed: {
			...mapState({
				token: state => state.user.token,
				longitude: state => state.user.longitude,
				latitude: state => state.user.latitude,
			}),
		},
		
		data() {
			return {
				pageState: 1, // 待审核
				list: [], // 列表
				loading: false, // 加载状态
				currentPage: 1,
				pageSize: 20,
				total: 0,
			}
		},
		
		onShow() {
			this.findList()
		},
		
		methods: {
			// 查询列表
			findList() {
				let params = {
					state: 0,
					token: this.token,
					stepNum: 4
				}
				
				this.loading = true
				
				getExamineList(params).then(res => {
					this.loading = false
					this.list = res.Result
					this.total = res.Result.length
				}).catch(err => {
					this.loading = false
				})
			},
			
			// 跳转到详情页
			toDetails(row) {
				uni.navigateTo({
					url: `/pages/repairManagerExamine/details/details?pageState=${ this.pageState }&id=${ row.terminalRno }&repairTaskId=${ row.repairTaskId }`
				})
			},
		}
	}
</script>

<style>

</style>
